﻿using System;
using System.Collections.Generic;
using System.Text;

namespace 设计模式
{
    class Leifeng
    {
        public void Sweep() {
            Console.WriteLine("扫地");
        }

        public void Wash() {
            Console.WriteLine("洗衣");
        }

        public void BuyRice()
        {
            Console.WriteLine("买米");
        }


    }


    class Undergraduate : Leifeng { }

    class Volunteer : Leifeng { }





    interface IFactory {
        Leifeng CreateLeiFeng();
    }

    class UndergraduateFactory : IFactory
    {
        public Leifeng CreateLeiFeng() {
            return new Undergraduate();
        }
    }


    class VolunteerFactory : IFactory
    {
        public Leifeng CreateLeiFeng()
        {
            return new  Volunteer();
        }
    }



    class Xueleifeng {
        public static void main() {
            IFactory factory = new UndergraduateFactory();
            Leifeng student = factory.CreateLeiFeng();
            student.Sweep();
            student.Wash();
            student.BuyRice();

            Console.Read();
        }
    }

}
